<template>
	<view>
		<view v-if="testList.length === 0">
			<image style="width: 400rpx;height: 400rpx; position: absolute; left: 20%; top:20%"
				src="https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/wujilu.png" mode=""></image>
		</view>
		<view v-else>
			<uni-card v-for="(item,index) in testList" :key="index" :title="item.name" :extra="item.className" @click="toTest(item)">
				<view>
					<text>测试课程：{{item.courseName}}</text>
				</view>
				<view>
					<text>测试章节：{{item.sectionName}}</text>
				</view>
				<view>
					<text>班级人数：{{item.classNum}}</text>
				</view>
				<view>
					<text>完成人数：{{item.passNum}}</text>
				</view>
				<view>
					<text :class="{'bad':item.unPassNum > 0 }">未完成数：{{item.unPassNum}}</text>
				</view>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import classTest from '@/api/modules/classTest'; 
	
	export default {
		data() {
			return {
				userId : uni.getStorageSync("loginId"),
				testList: [],
			}
		},
		created() {
			this.getTestCount();
		},
		methods: {
			getTestCount() {
				classTest.getTestCount(this.userId).then(res=> {
					this.testList=res.data
				}).catch(err => {
					uni.showToast({
						title: '加载失败,稍后重试...',
						icon: "error"
					})
				})
			},
			toTest(item) {
				uni.navigateTo({
					url: `/pages_duty/classTeacher/classTest/classTestDetails?classId=${item.classId}&testId=${item.id}`
				})
			}
		}
	}
</script>

<style>

</style>
